package com.ruoyi.web.controller.picture;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.picture.domain.Paccount;
import com.ruoyi.picture.service.IPaccountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 账单管理Controller
 * 
 * @author ruoyi
 * @date 2024-01-09
 */
@RestController
@RequestMapping("/paccount/paccount")
public class PaccountController extends BaseController
{
    @Autowired
    private IPaccountService paccountService;

    /**
     * 查询账单管理列表
     */
    @PreAuthorize("@ss.hasPermi('paccount:paccount:list')")
    @GetMapping("/list")
    public TableDataInfo list(Paccount paccount)
    {
        startPage();
        List<Paccount> list = paccountService.selectPaccountList(paccount);
        return getDataTable(list);
    }

    /**
     * 导出账单管理列表
     */
    @PreAuthorize("@ss.hasPermi('paccount:paccount:export')")
    @Log(title = "账单管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Paccount paccount)
    {
        List<Paccount> list = paccountService.selectPaccountList(paccount);
        ExcelUtil<Paccount> util = new ExcelUtil<Paccount>(Paccount.class);
        util.exportExcel(response, list, "账单管理数据");
    }

    /**
     * 获取账单管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('paccount:paccount:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(paccountService.selectPaccountById(id));
    }

    /**
     * 新增账单管理
     */
    @PreAuthorize("@ss.hasPermi('paccount:paccount:add')")
    @Log(title = "账单管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Paccount paccount)
    {
        return toAjax(paccountService.insertPaccount(paccount));
    }

    /**
     * 修改账单管理
     */
    @PreAuthorize("@ss.hasPermi('paccount:paccount:edit')")
    @Log(title = "账单管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Paccount paccount)
    {
        return toAjax(paccountService.updatePaccount(paccount));
    }

    /**
     * 删除账单管理
     */
    @PreAuthorize("@ss.hasPermi('paccount:paccount:remove')")
    @Log(title = "账单管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(paccountService.deletePaccountByIds(ids));
    }
}
